package models

import "xorm.io/builder"

type City struct {
	Id         int    `xorm:"not null pk autoincr comment('自增主键') INT(11)"`
	ProvinceId int64  `xorm:"comment('省份id 对应dts_province中的id') INT(11)"`
	CityId     int64  `xorm:"comment(' 城市id') INT(11)"`
	CityName   string `xorm:"comment('城市名') VARCHAR(64)"`
	CityPlate  string `xorm:"comment('城市车牌号头2位') VARCHAR(64)"`
}

type CityList struct {
	CityId   int    `json:"id"`
	CityName string `json:"value"`
}

func (c *City) GetCity(filter builder.Cond) (list []*CityList, err error) {
	err = engine.Table("dts_city").And(filter).Find(&list)
	return list, nil
}

func (c *City) GetByCityId(cityId string) (has bool, list CityList, err error) {
	has, err = engine.Table("dts_city").Where("city_id = ?", cityId).Get(&list)
	return
}
